package com.aqie.medium.dynamicProgram;

import java.util.Arrays;

/**
 * 62 todo
 * m * n 矩阵 不同路径
 */
public class UniquePaths {
    /**
     * dp[i][j] = dp[i-1][j] + dp[i][j-1], 每次只记录这两个数
     * @param m
     * @param n
     * @return
     */
    public int uniquePaths(int m, int n) {
        int[] cur = new int[n];
        Arrays.fill(cur,1);
        for (int i = 1; i < m;i++){
            for (int j = 1; j < n; j++){
                cur[j] += cur[j-1] ;
            }
        }
        return cur[n-1];
    }
}
